package com.czk.model.template.jdk8;

import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * 使用supplier和consumer方式
 *
 * @Author:ChenZhangKun
 * @Date: 2021/8/23 11:41
 */
public class BankBusinessHandler_2 {
    private Integer getNumber(Supplier<Integer> supplier) {
        // 拿到值
        return supplier.get();
    }

    private void judge() {
        System.out.println("give a praised");
    }
    public void execute(Supplier<Integer> supplier, Consumer<String> consumer){
        // 取号
        Integer number = getNumber(supplier);
        //
        if (number%2==0){
            consumer.accept(number+"");
            System.out.println("是偶数");
        }else {
            consumer.accept(number+"");
            System.out.println("是奇数");
        }
        judge();
    }
}
